home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / admin / xinetd.2 / xinetd / xinetd.2.1.7-linux.4 / libs / src / sio / sioconf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-10  |  5.0 KB  |  188 lines

  1. /*
  2.  * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  3.  * All rights reserved.  The file named COPYRIGHT specifies the terms 
  4.  * and conditions for redistribution.
  5.  */
  6.  
  7.  
  8. /*
  9.  * $Id: sioconf.h,v 1.2 1995/09/10 18:35:09 chuck Exp $
  10.  */
  11.  
  12. /*
  13.  * This file has 2 sections:
  14.  *        1. a OS-specific section
  15.  *        2. a CPU/compiler-specific section
  16.  *
  17.  * You can override/redefing any of the constants/macros in this file.
  18.  * by uncommenting the inclusion of customconf.h and placing your own
  19.  * definitions in that file.
  20.  */
  21.  
  22. #ifdef linux
  23. #include "customconf.h"
  24. #endif
  25.  
  26.  
  27.  
  28. /*
  29.  * OS-specific section.
  30.  *
  31.  * Features here use the flag HAS_<feature>.
  32.  * List of flags (check the following for macros that can be overriden):
  33.  *
  34.  *            HAS_MMAP (overridable macros)
  35.  *
  36.  *            HAS_ATEXIT
  37.  *            HAS_ONEXIT
  38.  *            HAS_OTHER_FINALIZER    (must define macros)
  39.  *
  40.  *            HAS_MEMOPS
  41.  *            HAS_BCOPY             (HAS_MEMOPS will be preferred if both are defined)
  42.  *
  43.  *    At least one of the following flags must be defined. The 2nd and 3rd
  44.  * flags are incompatible.
  45.  *            HAS_ISATTY
  46.  *            HAS_SYSVTTY
  47.  *            HAS_BSDTTY
  48.  */
  49.  
  50. /*
  51.  * Memory mapping.
  52.  *        The library requires 3 macros: SIO_MMAP, SIO_MUNMAP, SIO_MNEED.
  53.  *        You can selectively override any of them.
  54.  *        Notice that the SIO_MNEED macro is not required. If your system
  55.  *        does not have madvise, you can define the macro as:
  56.  *            #define SIO_MNEED( addr, len )
  57.  */
  58. #ifdef HAS_MMAP
  59.  
  60. #if !defined( SIO_MMAP ) || !defined( SIO_MUNMAP ) || !defined( SIO_MNEED )
  61. #include <sys/types.h>
  62. #include <sys/mman.h>
  63. #endif
  64.  
  65. #ifndef SIO_MMAP
  66. #define SIO_MMAP( addr, len, fd, off )                                  \
  67.          mmap( addr, len, PROT_READ,                                    \
  68.             ( addr == 0 ) ? MAP_PRIVATE : MAP_PRIVATE + MAP_FIXED,      \
  69.                fd, off )
  70. #endif
  71.  
  72. #ifndef SIO_MUNMAP
  73. #define SIO_MUNMAP( addr, len )  munmap( addr, len )
  74. #endif
  75.  
  76. #ifndef SIO_MNEED
  77. #define SIO_MNEED( addr, len )      (void) madvise( addr, len, MADV_WILLNEED )
  78. #endif
  79.  
  80. #endif    /* HAS_MMAP */
  81.  
  82. /*
  83.  * N_SIO_DESCRIPTORS is the maximum number of file descriptors
  84.  * supported by the OS
  85.  */
  86. #ifndef N_SIO_DESCRIPTORS
  87. #include <sys/param.h>
  88. #define N_SIO_DESCRIPTORS        NOFILE
  89. #endif
  90.  
  91.  
  92.  
  93. /*
  94.  * Finalization function. 
  95.  *
  96.  * The purpose of this function is to do work after your program has
  97.  * called exit(3). In the case of SIO, this means flushing the SIO
  98.  * output buffers.
  99.  *
  100.  * If your system does not support atexit or onexit but has some other
  101.  * way of installing a finalization function, you define the flag 
  102.  * HAS_FINALIZER. Then you must define the macros 
  103.  *            SIO_FINALIZE and SIO_DEFINE_FIN
  104.  *
  105.  * SIO_FINALIZE attempts to install a finalization function and returns TRUE 
  106.  * if successful, FALSE if unsuccessful.
  107.  * SIO_DEFINE_FIN defines the finalization function (the reason for this macro
  108.  * s that different systems pass different number/type of arguments to the
  109.  * finalization function; the SIO finalization function does not use any
  110.  * arguments).
  111.  */
  112. #if defined(HAS_ONEXIT) || defined(HAS_ATEXIT) || defined(HAS_FINALIZER)
  113.  
  114. #define HAS_FINALIZATION_FUNCTION
  115.  
  116. #if defined( HAS_ONEXIT ) && defined( HAS_ATEXIT )
  117. #undef HAS_ONEXIT
  118. #endif
  119.  
  120. #ifdef HAS_ONEXIT
  121. #define SIO_FINALIZE( func )        ( on_exit( func, (caddr_t) 0 ) == 0 )
  122. #define SIO_DEFINE_FIN( func )      static void func ( exit_status, arg )  \
  123.                                           int exit_status ;                \
  124.                                           caddr_t arg ;
  125. #endif    /* HAS_ONEXIT */
  126.  
  127. #ifdef HAS_ATEXIT
  128. #define SIO_FINALIZE( func )        ( atexit( func ) == 0 )
  129. #define SIO_DEFINE_FIN( func )      static void func ()
  130. #endif    /* HAS_ATEXIT */
  131.  
  132. #endif    /* HAS_ONEXIT || HAS_ATEXIT || HAS_FINALIZER */
  133.  
  134.  
  135. /*
  136.  * HAS_MEMOPS should be defined if your OS supports the mem* functions
  137.  * (memcpy etc). If not, then you can define HAS_BCOPY if your OS supports 
  138.  * bcopy.
  139.  */
  140. #if defined( HAS_MEMOPS ) && defined( HAS_BCOPY )
  141. #undef HAS_BCOPY
  142. #endif
  143.  
  144.  
  145. /*
  146.  * Support for the isatty(3) function. This function identifies if a 
  147.  * desciptor refers to a terminal.
  148.  *
  149.  * Case 1: isatty(3) is in the C library
  150.  *        --> define HAS_ISATTY
  151.  *    Case 2: no isatty(3), BSD 4.3 tty handling
  152.  *        --> define HAS_BSDTTY
  153.  * Case 3: no isatty(3), System V tty handling
  154.  *        --> define HAS_SYSVTTY
  155.  *
  156.  * The following code checks:
  157.  *        1) that at least one of the flags is defined
  158.  *        2) only one of the BSD, SYS V flags is defined
  159.  */
  160. #if !defined(HAS_ISATTY) && !defined(HAS_BSDTTY) && !defined(HAS_SYSVTTY)
  161. ERROR function_isatty_not_available ;
  162. #endif
  163.  
  164. #ifdef HAS_ISATTY
  165. #undef HAS_BSDTTY
  166. #undef HAS_SYSVTTY
  167. #endif
  168.  
  169. #if defined(HAS_BSDTTY) && defined(HAS_SYSVTTY)
  170. ERROR HAS_BSDTTY_and_HAS_SYSVTTY_both_defined ;
  171. #endif
  172.  
  173.  
  174.  
  175. /*
  176.  * CPU/compiler-specific section.
  177.  *
  178.  * The following constant affects the behavior of Sprint.
  179.  *
  180.  * Sprint performs integer->string conversions by first converting
  181.  * the integer to the widest int type supported by the CPU/compiler.
  182.  * By default, this is the "long int" type. If your machine has
  183.  * a wider type, you can specify it by defining the WIDE_INT constant.
  184.  * For example:
  185.  *        #define WIDE_INT                    long long
  186.  */
  187.  
  188.